package com.example.bili.controller;

import com.example.bili.entity.Comments;
import com.example.bili.service.CommentsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cmt")
public class CmtController {

    @Resource
    private CommentsService commentsService;

    @GetMapping("/getCmtNum/{becment}")
    public Object getCmtNum(@PathVariable int becment){
        return commentsService.getCmtNum(becment);
    }

    @GetMapping("/getCmtAll/{becment}")
    public Object getCmtAll(@PathVariable int becment){
        return commentsService.getCmtAll(becment);
    }

    @GetMapping("/getCmtZi")
    public Object getCmtZi(@RequestParam(required = false)int becment,
                           @RequestParam(required = false)int fuId){
        return commentsService.getCmtZi(becment,fuId);
    }

    @PostMapping("/addCmt")
    public Object addCmt(@RequestBody Comments cmt){
        return commentsService.addCmt(cmt);
    }

    @GetMapping("/delCmt/{id}")
    public Object delCmt(@PathVariable int id){
        return commentsService.delCmt(id);
    }
}
